import {Button, message, Popconfirm} from "antd";
import {DeleteOutlined} from "@ant-design/icons";

type DangerButtonType = {
    description: string
    onConfirm: () => void
}

export const DangerButton = (props: DangerButtonType) => {

    const cancel = () => {
        message.error('您取消了删除')
    }

    const confirm = () => {
        props.onConfirm()
    }

    return (
        <Popconfirm
            title={'提示'}
            okText={'确认'}
            cancelText={'取消'}
            description={props.description}
            onCancel={cancel}
            onConfirm={confirm}
        >
            <Button
                danger
                type={'link'}
                icon={<DeleteOutlined />}
            >删除</Button>
        </Popconfirm>
    )
}